import java.util.ArrayList;
import java.util.Comparator;
import java.util.HashMap;
import java.util.function.BiConsumer;

/**
 * Created with IDEA
 * author:ju bai
 * Date:2021/3/3
 * Time:16:27
 **/
public class TestDemo4 {
    public static void main(String[] args) {
        HashMap<Integer, String> map = new HashMap<>();
        map.put(1, "hello");
        map.put(2, "bit");
        map.put(3, "hello");
        map.put(4, "lambda");

        map.forEach(new BiConsumer<Integer, String>() {
            @Override
            public void accept(Integer integer, String s) {
                System.out.println(integer+" "+s);
            }
        });

        /*map.forEach((k,v)->{
            System.out.println(k+" "+v);
        });*/

        System.out.println("================");
        map.forEach((k,v) -> System.out.println(k+" "+v));
    }
    public static void main2(String[] args) {
        ArrayList<String> list = new ArrayList<>();
        list.add("Hello");
        list.add("bit");
        list.add("hello");
        list.add("lambda");
        list.sort(new Comparator<String>() {
            @Override
            public int compare(String o1, String o2) {
                return o1.compareTo(o2);
            }
        });
        //list.sort((String o1,String o2)->{return o1.compareTo(o2);});
        list.sort((o1, o2)->  o1.compareTo(o2) );

        list.forEach(s-> System.out.println(s));
    }
    public static void main1(String[] args) {
        ArrayList<String> list = new ArrayList<>();
        list.add("Hello");
        list.add("bit");
        list.add("hello");
        list.add("lambda");
        /*list.forEach(new Consumer<String>() {
            @Override
            public void accept(String s) {
                System.out.println(s);
            }
        });*/
        /*list.forEach((String s) -> {
            System.out.println(s);
        });*/
        list.forEach(s->System.out.println(s));
    }
}

